package com.aloudmeta.grpc.client;

import com.aloudmeta.grpc.demo2.EchoRequest;
import com.aloudmeta.grpc.demo2.EchoResponse;
import com.aloudmeta.grpc.demo2.Proto2EchoServiceGrpc;
import io.grpc.ManagedChannel;
import io.grpc.ManagedChannelBuilder;

/**
 * huaixin 2022/1/22 3:54 PM
 */
public class Proto2DuuboEchoClient {
    public static void main(String[] args) {
        ManagedChannel channel = ManagedChannelBuilder.forAddress("localhost", 50051)
                .usePlaintext()
                .build();
        Proto2EchoServiceGrpc.Proto2EchoServiceBlockingStub stub =
                Proto2EchoServiceGrpc.newBlockingStub(channel);
        for (int i = 0; i < 8; i++) {
            EchoResponse response = stub.echo(EchoRequest.newBuilder()
                    .setMessage("Hello!")
                    .build());
            System.out.println(response.getMessage());
        }
    }
}
